﻿//cesium 三维的影响结构数据 -->
// 初始化地图

var map3dcesiumimg = (function () {
    // 初始化
    function map3dcesiumimg() {
        // 属性
        
    };
    map3dcesiumimg.prototype.resize = function (options) {
        console.info("map3dcesiumimgresize");
    }
    ////
    map3dcesiumimg.prototype.init = function (options) {
        var that = this;
       
        this.viewer = new Cesium.Viewer(
            options.id, {
                skyBox: false,                
                baseLayerPicker: false,
                //imageryProvider: transparentBaseLayer,
                scene3DOnly: true,
                imageryProvider: new Cesium.WebMapTileServiceImageryProvider({
                    url: "http://{s}.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles",
                    layer: "tdtBasicLayer",
                    style: "default",
                    format: "image/jpeg",
                    tileMatrixSetID: "GoogleMapsCompatible",
                    show: true,
                    maximumLevel: 18,
                    subdomains: ['t1', 't2', 't3', 't4', 't5']
                }),
                contextOptions: {
                    webgl: {
                        alpha: true
                    }
                },
                animation: false,
                fullscreenButton: false,
                geocoder: false,
                homeButton: false,
                infoBox: false,
                sceneModePicker: false,
                selectionIndicator: false,
                timeline: false,
                navigationHelpButton: false,
                navigationInstructionsInitiallyVisible: false
 
            });
        //Set the background of the scene to transparent
        that.viewer.scene.backgroundColor = Cesium.Color.TRANSPARENT;

        //Set the globe base color to transparent
        //that.viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;

       
        that.viewer.scene.fxaa = false;

        //var rectangle = Cesium.Rectangle.fromDegrees(-115.0, 37.0, -107, 40);
        //Add our region limited imagery
         

        //that.viewer.camera.viewRectangle(rectangle);

        var previousTime = Date.now();
        function onTickCallback(clock) {
            var spinRate = 0.1;
            var currentTime = Date.now();
            var delta = (currentTime - previousTime) / 1000;
            previousTime = currentTime;
            that.viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, spinRate * delta);
        }
        viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude, 1000.0)
        });
        handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

        var unsubscribeTicks = that.viewer.clock.onTick.addEventListener(onTickCallback);
    }
    // 返回
    return map3dcesiumimg;
})();